<page-header [title]="l('Books')" [desc]="l('书籍列表内容')"></page-header>

<nz-card [nzBordered]='false'>



  <!--模糊搜索文本框-->
  <div class="mb-md">
    <nz-row nzGutter="8">
      <nz-col nzSm="24">
        <nz-form-item>
          <nz-form-control>
            <nz-input-group nzSearch [nzSuffix]="suffixSearchButton">
              <input type="text" nz-input [(ngModel)]="filterText" id="filterText" name="filterText"
                (keyup.enter)="refresh()" [placeholder]="l('SearchWithThreeDot')">
              <ng-template #suffixSearchButton>
                <button nz-button nzType="primary" nzSearch type="submit" (click)="refresh()">
                  <i class="anticon anticon-search"></i>
                </button>
              </ng-template>
            </nz-input-group>
          </nz-form-control>
        </nz-form-item>
      </nz-col>
    </nz-row>
  </div>
  <!--添加按钮-->
  <div class="mb-md">
    <nz-row nzGutter="8">
      <nz-col nzSm="12" nzMd="20" class="btn-gutter">
        <button (click)="CreateOrEdit()" nzType="primary" nz-button><i
            class="anticon anticon-plus"></i><span>{{l('Create')}}</span></button>
        <button (click)="batchDelete()" nz-button nzType="danger">
          <i class="anticon anticon-delete"></i>
          <span>{{l('BatchDelete')}}</span>
        </button>
      </nz-col>
    </nz-row>
  </div>

  <!--复选框提供的刷新，清空全选功能的点-->
  <div class="mb-md">
    <nz-row nzGutter="8">
      <nz-alert nzType="info" [nzMessage]="message" [nzShowIcon]="true">
        <ng-template #message>
          <span [innerHTML]="l('GridSelectedXItemsTips',selectedDataItems.length)"></span>
          <a (nzClick)="reset($event)" class="ml-md">
            {{l('clearEmpty')}}
          </a>
          <nz-divider nzType="vertical"></nz-divider>
          <a (nzClick)="onClick($event)">
            {{l('Refresh')}}
          </a>
        </ng-template>
      </nz-alert>
    </nz-row>
  </div>

  <!--实体表格内容呈现-->
  <nz-row nzGutter="8">
    <nz-table #ajaxTable [nzData]="dataList" [nzPageSize]="pageSize" [(nzPageIndex)]="pageNumber" [nzTotal]="totalItems"
      [nzLoading]="true" (nzPageIndexChange)='pageNumberChange()' (nzPageSizeChange)='refresh()'
      [nzShowSizeChanger]="true" [nzShowQuickJumper]="true" [nzNoResult]="noDataTemplate"
      [nzShowTotal]="showTotalTemplate" [nzFrontPagination]="false">
      <!--暂无数据组件-->
      <ng-template #noDataTemplate>
        <no-data></no-data>
      </ng-template>
      <!--分页信息增强内容-->
      <ng-template #showTotalTemplate let-total let-range=range>
        {{l('GridFooterDisplayText',pageNumber,totalPages,total,range[0],range[1])}}
      </ng-template>
      <thead (nzSortChange)="gridSort($event)">
        <tr>
          <!--表头内容-->
          <th nzShowCheckbox [(nzChecked)]="allChecked" [nzDisabled]="allCheckboxDisabled"
            [nzIndeterminate]="checkboxIndeterminate" (nzCheckedChange)="checkAll($event)"></th>

          <th nz-th nzShowSort nzSortKey="ImgUrl" nzWidth="100px">
            <span>{{l('ImgUrl')}}</span>
          </th>
          <th nz-th nzShowSort nzSortKey="Name" nzWidth="100px">
            <span>{{l('Name')}}</span>
          </th>
          <th nz-th nzShowSort nzSortKey="Author" nzWidth="100px">
            <span>{{l('Author')}}</span>
          </th>
          <th nz-th nzShowSort nzSortKey="Intro" nzWidth="100px">
            <span>{{l('Intro')}}</span>
          </th>
          <th nzWidth="230px" class="text-center">
            <span>{{l('Actions')}}</span>
          </th>
        </tr>
      </thead>
      <!--表格内容-->
      <tbody>
        <tr *ngFor="let item of ajaxTable.data">
          <td>
            <img [src]=item.imgUrl>
          </td>
          <td>
            <ellipsis lines="1">
              <span nz-tooltip [nzTitle]="item.name">{{item.name}}</span>
            </ellipsis>
          </td>
          <td>
            <ellipsis lines="1">
              <span nz-tooltip [nzTitle]="item.author">{{item.author}}</span>
            </ellipsis>
          </td>
          <td>
            <ellipsis lines="1">
              <span nz-tooltip [nzTitle]="item.intro">{{item.intro}}</span>
            </ellipsis>
          </td>
          <!--操作-->
          <td>
            <ng-container>
              <a (click)="createOrEdit(item.id)">
                <i class="anticon anticon-edit mr-sm"></i>
                <span>{{l('Edit')}}</span>
              </a>
            </ng-container>
          </td>
        </tr>
      </tbody>
    </nz-table>
  </nz-row>
</nz-card>